function loadMenu(topic_id)
{
	$.ajax({  
		type: "POST",  
        url: '../WebSubject/loadSubjectMenus.json',  
        data:{  
        	topic_id:topic_id,		    	    	  
	    },  
	    cache:false,  
	    dataType:'json',  
	    success:function(data) { 
	    	if(data!=null && data.length>0){
	    		loadToptMenu(data);
	    	}	
	    },  
	     error : function(XMLHttpRequest, textStatus, errorThrown) {  
	          alert("获取专题栏目异常！");  
	          alert(XMLHttpRequest.status);
	          alert(XMLHttpRequest.readyState);
	          alert(textStatus);
	     }  
	});	

}

function loadIndexLeftMenu(topic_id)
{
	$.ajax({  
		type: "POST",  
        url: '../WebSubject/loadSubjectMenus.json',  
        data:{  
        	topic_id:topic_id,		    	    	  
	    },  
	    cache:false,  
	    dataType:'json',  
	    success:function(data) { 
	    	if(data!=null && data.length>0){
	    		loadLeftMen(data);
	    		
	    		localMsgTitle(data);  //加载面页内容.
	    	}	
	    },  
	     error : function(XMLHttpRequest, textStatus, errorThrown) {  
	          alert("获取专题栏目异常！");  
	          alert(XMLHttpRequest.status);
	          alert(XMLHttpRequest.readyState);
	          alert(textStatus);
	     }  
	});	

}



//初始化顶部菜单,
function loadToptMenu(data)
{
	var str="";
	for(var i = 0; i< data.length; i++)
	{
		str+="<td width='105' align='center'> <a href='../WebSubject/SubMenuPage.htm?id="+data[i].id+"'>"+data[i].title+"</a></td>";
	}
	
	
/*	
 * ie9 以下不支持data.forEach（）
 * data.forEach(function(e){  
			str+="<td width='105' align='center'> <a href='../WebSubject/SubMenuPage.htm?id="+e.id+"'>"+e.title+"</a></td>";
	});*/
	$("#top_menu").append(str);  //添加页面显示样式.
}


function loadLeftMen(data)
{
	
	var str="";
	for(var i = 0; i< data.length; i++)
	{
		str+="<tr>";
		str+="<td height='36' valign='bottom'";
		str+="	background='../../../../images/banger_h77.jpg'>";
		str+="	<table border='0' cellspacing='0' cellpadding='0'";
		str+="		width='100%' height='32'>";
		str+="		<tbody>";
		str+="			<tr>";
		str+="				<td width='12%'>&nbsp;</td>";
		str+="				<td class='f18' width='88%'>";
						
		str+="				<a href='../WebSubject/SubMenuPage.htm?id="+data[i].id+"'>"+data[i].title+"</a></td>";
		str+="			</tr>";
		str+="		</tbody>";
		str+="</table>";
		str+="</td>";
		str+="</tr>";
	}
	
	
	/*
	data.forEach(function(e){  
		str+="<tr>";
		str+="<td height='36' valign='bottom'";
		str+="	background='../../../../images/banger_h77.jpg'>";
		str+="	<table border='0' cellspacing='0' cellpadding='0'";
		str+="		width='100%' height='32'>";
		str+="		<tbody>";
		str+="			<tr>";
		str+="				<td width='12%'>&nbsp;</td>";
		str+="				<td class='f18' width='88%'>";
						
		str+="				<a href='../WebSubject/SubMenuPage.htm?id="+e.id+"'>"+e.title+"</a></td>";
		str+="			</tr>";
		str+="		</tbody>";
		str+="</table>";
		str+="</td>";
		str+="</tr>";
	});*/
	$("#left_menu").append(str); 
}
	
	
	function loadSecPageMenu(topic_id)
	{
		$.ajax({  
			type: "POST",  
	        url: '../WebSubject/loadSubjectMenus.json',  
	        data:{  
	        	topic_id:topic_id,		    	    	  
		    },  
		    cache:false,  
		    dataType:'json',  
		    success:function(data) { 
		    	if(data!=null && data.length>0){
		    		loadToptMenu(data);
		    	}	
		    },  
		     error : function(XMLHttpRequest, textStatus, errorThrown) {  
		          alert("获取专题栏目异常！");  
		          alert(XMLHttpRequest.status);
		          alert(XMLHttpRequest.readyState);
		          alert(textStatus);
		     }  
		});	

	}
	
	
	function loadSecMenu(menu_id)
	{
		$.ajax({  
 			type: "POST",  
 	        url: '../WebSubject/loadTreeMenus.json',  
 	        data:{  
 	        	id:menu_id,		    	    	  
 		    },  
 		    cache:false,  
 		    dataType:'json',  
 		    success:function(data) { 
 		    	if(data!=null && data.length>0){
 		    		loadLeftMen(data);
 		    		
 		    		//localMsgTitle(data);
 		    	}
 		    },  
 		     error : function() {  
 		          alert("获取专题信息异常！");  
 		     }  
 		});
	}
	
	
	
	
	
	
	function getTitleMsg(topic_id, menuId, flag)
	{
		var str="";
		$.ajax({  
			type: "POST",  
	        url: '../WebSubject/loadSubjectMsgByFlag.json',  
	        async: false,
	        data:{  
	        	topic_id:topic_id,
	        	id :menuId,
	        	flag:flag,
		    },  
		    cache:false,  
		    dataType:'json',  
		    success:function(data) { 
		    	if(data!=null && data.length>0){
		    		
		    		for (var i=0;i<data.length;i++)
		    		{
		    			var href = "../WebSubject/detailMsgPage.htm?id="+data[i].id +"&menu_id=" +menuId;
		    			if(data[i].isLink == '1')
		    			{
		    				href=data[i].linkURL;
		    			}
		    			
		    			var d = data[i].createTime;
						var test = new Date(parseInt(d));  
						var _year = test.getFullYear();  
						var _month = parseInt(test.getMonth())+1;  
						var _day = test.getDate();  
		    			
		    			str+="<tr>";
		    			str+="<td height='28'";
		    			str+="	background='../../../../images/tit_bg001.png'><a";
		    			str+="	href='"+href+"'";
		    			str+="	target='_blank'";
		    			str+="	title='"+data[i].title+"'>" + data[i].title;
						str+="</a></td>";
						str+="	<td width='130'";
						str+="	background='../../../../images/rmyh_pic4.jpg'><div";
						str+="		align='center' class='f12'>["+_year+"年"+_month+"月"+_day+"日]</div></td>";
						str+="</tr>";

		    		}
		    	}	
		    },  
		     error : function(XMLHttpRequest, textStatus, errorThrown) {  
		          alert("获取政策文件信息异常！");  
		          alert(XMLHttpRequest.status);
		          alert(XMLHttpRequest.readyState);
		          alert(textStatus);
		     }  
		});
		return str;
	}
	
	
	
	
	
	/**
	 * 循环迭菜单项
	 */
	
	
	function localMsgTitle(data)
	{
		
		var smgStr = "";
		for(var i = 0; i< data.length; i++)
		{
			smgStr+="<table border='0' cellspacing='1' cellpadding='0'";
			smgStr+="	width='96%' bgcolor='#d4d4d4' align='center'>";
			smgStr+="	<tbody>";
			smgStr+="		<tr>";
			smgStr+="			<td bgcolor='#ffffff' height='33' background='../../../../images/banger_h16.jpg'>";
			smgStr+="				<table border='0' cellspacing='0' cellpadding='0'";
			smgStr+="width='100%'>";
			smgStr+="<tbody>";
			smgStr+="<tr>";
			smgStr+="<td width='25'><img";
			smgStr+="	src='../pages/WebSubject/psInfoDisclosure/images/navigation_right_frame.png' width='36'";
			smgStr+="								height='36'></td>";
			smgStr+="							<td class='f13'>"+data[i].title+"</td>";
			smgStr+="						</tr>";
			smgStr+="					</tbody>";
			smgStr+="				</table>";
			smgStr+="			</td>";
			smgStr+="		</tr>";
			smgStr+="		<tr>";
			smgStr+="			<td bgcolor='#ffffff'>";
			smgStr+="				<table border='0' cellspacing='0' cellpadding='0'";
			smgStr+="						width='98%' align='center'>";
			smgStr+="						<tbody>";
			smgStr+="							<tr>";
			smgStr+="							<td height='7'></td>";
			smgStr+="					</tr>";

			smgStr+=getTitleMsg(data[i].topic_id,data[i].id , data[i].flag);				
									
									
			smgStr+="<tr>";
			smgStr+="<td height='18' colspan='2'>";
			smgStr+="<div align='right'>";
			smgStr+="<a href='../WebSubject/SubMenuPage.htm?id="+data[i].id+"' target='_blank'>更多&gt;&gt;</a>";
			smgStr+="								</div>";
			smgStr+="							</td>";
			smgStr+="						</tr>";
			smgStr+="						</tbody>";
			smgStr+="			</table>";
			smgStr+="			</td>";
			smgStr+="		</tr>";
			smgStr+="	</tbody>";
			smgStr+="</table>";
		}
		
		
		
		
		/*data.forEach(function(e){  
			smgStr+="<table border='0' cellspacing='1' cellpadding='0'";
			smgStr+="	width='96%' bgcolor='#d4d4d4' align='center'>";
			smgStr+="	<tbody>";
			smgStr+="		<tr>";
			smgStr+="			<td bgcolor='#ffffff' height='33' background='../../../../images/banger_h16.jpg'>";
			smgStr+="				<table border='0' cellspacing='0' cellpadding='0'";
			smgStr+="width='100%'>";
			smgStr+="<tbody>";
			smgStr+="<tr>";
			smgStr+="<td width='25'><img";
			smgStr+="	src='../pages/WebSubject/psInfoDisclosure/images/navigation_right_frame.png' width='36'";
			smgStr+="								height='36'></td>";
			smgStr+="							<td class='f13'>"+e.title+"</td>";
			smgStr+="						</tr>";
			smgStr+="					</tbody>";
			smgStr+="				</table>";
			smgStr+="			</td>";
			smgStr+="		</tr>";
			smgStr+="		<tr>";
			smgStr+="			<td bgcolor='#ffffff'>";
			smgStr+="				<table border='0' cellspacing='0' cellpadding='0'";
			smgStr+="						width='98%' align='center'>";
			smgStr+="						<tbody>";
			smgStr+="							<tr>";
			smgStr+="							<td height='7'></td>";
			smgStr+="					</tr>";

			smgStr+=getTitleMsg(e.topic_id,e.id , e.flag);				
									
									
			smgStr+="<tr>";
			smgStr+="<td height='18' colspan='2'>";
			smgStr+="<div align='right'>";
			smgStr+="<a href='../WebSubject/SubMenuPage.htm?id="+e.id+"' target='_blank'>更多&gt;&gt;</a>";
			smgStr+="								</div>";
			smgStr+="							</td>";
			smgStr+="						</tr>";
			smgStr+="						</tbody>";
			smgStr+="			</table>";
			smgStr+="			</td>";
			smgStr+="		</tr>";
			smgStr+="	</tbody>";
			smgStr+="</table>";
			
		});*/
		$("#msg_title").append(smgStr); 

	}
	
